import request from '@/utils/http/request'

export interface MenuResponse {
  children: ChildrenModel[]
}

export interface ChildrenModel {
  id?: string,
  gmtCreate: string,
  gmtModified: string,
  deleted: boolean,
  pid: string,
  name: string,
  code: string,
  toCode: string,
  type: number,
  status: null,
  level: number,
  children: ChildrenModel[],
  select: boolean
}

export interface FormModel {
  id?: string,
  name: string,
  code: string,
  level: number,
  pid: string,
  type: number,
  tocode: string
}

export const getMenuList = () => {
  return request.get<any, MenuResponse>('/admin/acl/permission')
}

export const remove = (id: string) => {
  return request.delete(`/admin/acl/permission/remove/${id}`)
}

export const update = (form: FormModel) => {
  return request.put('/admin/acl/permission/update', form)
}

export const save = (form: FormModel) => {
  return request.post('/admin/acl/permission/save', form)
}